
package com.platform.common.shiro;

import com.platform.common.enums.UserTypeEnum;
import com.platform.modules.sys.domain.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * Shiro工具类
 */
public class ShiroUtils {

    public static Subject getSubject() {
        return SecurityUtils.getSubject();
    }

    public static SysUser getUser() {
        return (SysUser) SecurityUtils.getSubject().getPrincipal();
    }

    public static Long getRoleId() {
        return getUser().getRoleId();
    }

    public static String getSessionId() {
        return SecurityUtils.getSubject().getSession().getId().toString();
    }

    public static boolean isAdmin(SysUser user) {
        return UserTypeEnum.PLATFORM.getCode().equals(user.getUserType());
    }

}
